package com.gry.Test;

import java.util.ArrayList;

public class UserTest {
    public static void main(String[] args) {
        ArrayList<User> list = new ArrayList<>();
        User u1 = new User(1, "gry", "123");
        User u2 = new User(2, "rrr", "222");
        User u3 = new User(3, "yyy", "333");
        list.add(u1);
        list.add(u2);
        list.add(u3);
        System.out.println(check(list,4));
    }

    public static boolean check(ArrayList<User> list,int id){
        if (list == null){
            System.out.println("表为空");
            return false;
        }
        for (int i = 0; i < list.size(); i++) {
            if (id == list.get(i).getId()){
                return true;
            }
        }
        return false;
    }
}
